package com.cman777.springc.mybatis.idgenerator;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.cman777.springc.common.bean.Iface.EntityIFace;
import com.cman777.springc.common.helper.EntityUtil;
import com.cman777.springc.redis.util.UtilRedis;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author chenzhicong
 * @time 2020/3/17 7:14
 * @description
 */
public class RedisIdGenerator implements IdentifierGenerator {
    @Autowired
    private UtilRedis utilRedis;
    @Override
    public  Number nextId(Object entity) {
        String redisKey = EntityUtil.getIdRedisKey(entity.getClass());
        return utilRedis.nextId(redisKey, null);
    }
}
